import { checkPhone, checkCode } from '../utils/check.js'
// document.querySelector('.btn').addEventListener('click', () => {
//     const phone = document.querySelector('.login-form [name=mobile]').value
//     const code = document.querySelector('.login-form [name=code]').value
//     if (!checkPhone(phone)) {
//         alert('手机号格式不正确')
//         return
//     }
//     if (!checkCode(code)) {
//         alert('验证码不能为空')
//         return
//     }
//     alert('校验通过')
// })
import 'bootstrap/dist/css/bootstrap.min.css'
import './index.css'
import './index.less'
import myAxios from '../utils/request.js'
import { myAlert } from '../utils/alert.js'
document.querySelector('.btn').addEventListener('click', () => {
    const phone = document.querySelector('.login-form [name=mobile]').value
    const code = document.querySelector('.login-form [name=code]').value
    if (!checkPhone(phone)) {
        myAlert(false, '手机号格式不正确')
        return
    }
    if (!checkCode(code)) {
        myAlert(false, '验证码长度不对')
        return
    }
    myAxios({
        url: '/v1_0/authorizations',
        method: 'post',
        data: {
            mobile: phone,
            code: code
        }
    }).then(resp => {
        myAlert(true, '登陆成功')
        localStorage.setItem('token', resp.data.token)
        location.href = '../content/index.html'
    }).catch(err => {
        myAlert(false, err.response.data.message)
    })
})


if (process.env.NODE_ENV === 'production') {
    console.log = () => { }
}

import youAxiox from '@/utils/request.js'